package com.lzy.imagepickerdemo.zn.adapter;

import android.app.Activity;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lzy.imagepicker.ImagePicker;
import com.lzy.imagepickerdemo.GApp;
import com.lzy.imagepickerdemo.R;
import com.lzy.imagepickerdemo.imageloader.GlideImageLoader;
import com.lzy.imagepickerdemo.zn.db.PhotoTypeEntity;

/**
 * 作者：刘杰（QQ:770161055,WeChat:yjso0826）
 * 时间： 2018/5/25
 */
public class PersonalTypeAdapter extends BaseQuickAdapter<PhotoTypeEntity, BaseViewHolder> {
    private ImagePicker imagePicker;
    public PersonalTypeAdapter(){
        super(R.layout.personal_type_item);
        imagePicker = ImagePicker.getInstance();
        imagePicker.setImageLoader(new GlideImageLoader());
    }
    @Override
    protected void convert(BaseViewHolder helper, PhotoTypeEntity item) {
        helper.setText(R.id.tv_name,item.name).setText(R.id.tv_time,item.photo_type+"");
        if (imagePicker!=null)
            try {
                imagePicker.getImageLoader().displayImage((Activity) mContext, GApp.getInstance().mDBManager.getPhotolist(item.photo_type).get(0).img_url, (ImageView)helper.getView(R.id.im_photo), 188, 188);

            }catch (Exception e){
            e.printStackTrace();
            }

    }
}
